import { defineConfig } from 'vite'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
      symbolId: 'icon-[dir]-[name]',
    }),
  ],
  resolve: {
    alias: {
      '@': path.resolve('./src'), // 相对路径别名配置，使用 @ 代替 src
    },
  },
  server:{
    port:3001,
    proxy:{
      '/api':{
        target:'https://m.ximalaya.com',
        changeOrigin:true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '/dev-api':{
        target:'https://search.ximalaya.com',
        changeOrigin:true,
        rewrite:(path) => path.replace(/^\/dev-api/,''),
      },
      '/mylogin':{
        target:'http://sph-h5-api.atguigu.cn',
        changeOrigin:true,
        rewrite:(path) => path.replace(/^\/mylogin/,''),
      }
    }
  }
})
